home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk8 / asm / dump.asm < prev    next >
Assembly Source File  |  1995-03-18  |  4KB  |  113 lines

  1. ;
  2. ;   Dumper - file dump - Jim Butterfield.  March 15/88.
  3.  
  4. ; Exec library calls
  5.             xref _LVOOpenLibrary       ;-$228
  6.             xref _LVOCloseLibrary      ;-$19E
  7.             xref _LVOSetSignal         ;-$132
  8. ; DOS library calls
  9.             xref _LVOOpen              ;-$1E
  10.             xref _LVOClose             ;-$24
  11.             xref _LVOOutput            ;-$3C
  12.             xref _LVOWrite             ;-$30
  13.             xref _LVORead              ;-$2A
  14. ;
  15. ;-- Initial setup:
  16. Startup     move.l a0,a4             ; Remember ptr to argument line.
  17.             move.l d0,d4             ; Remember len of argument line.
  18.             lea    dosname(pc),a1    ;-Specify name 'dos.library'.
  19.             clr    d0                ;   Any version (0)
  20.             move.l $4,a6             ;   Then using Exec library,
  21.             jsr    _LVOOpenLibrary(a6)  ;   Open Dos library.
  22.             move.l d0,a6             ; Remember dosbase ptr.
  23.             beq    StartupQuit       ; Check for error (d0=0 means
  24.             bsr    DOSinit
  25.             move.l a6,a1             ;-Specify Dos library in a1;
  26.             move.l $4,a6             ;   then using Exec library,
  27.             jsr    _LVOCloseLibrary(a6)    ;   close Dos library.
  28. StartupQuit rts                      ; End of Program
  29. ;
  30. ;-- Get CLI outhandle:
  31. DOSinit     jsr    _LVOOutput(a6)    ;   get CLI outhandle,
  32.             move.l d0,a5             ;   & then remember it.
  33. ;
  34. ;-- Change arg file name to 'C string':
  35. checklen    move.b #0,-$1(a4,d4.W)   ; binary zero at end
  36. skipspc     cmp.b  #$20,(a4)+
  37.             beq    skipspc
  38.             subq   #1,a4
  39.             move.l a4,d1             ; filename pointer
  40.             move.l #1005,d2          ; MODE_OLDFILE (for reading)
  41.             jsr    _LVOOpen(A6)
  42.             move.l d0,d6             ; file inhandle
  43.             beq    DOSquit           ; no good, quit
  44.             bsr    DumpFile          ; the main job
  45.             move.l d6,d1             ; use the handle..
  46.             jsr    _LVOClose(A6)     ; to close the file
  47. DOSquit     rts                      ;   exit program.
  48. ;
  49. ; DOS is open and we have our in/out handles.  Let's go!
  50. DumpFile    moveq  #0,d7             ; zero column count
  51. ReadBlock   move.l d6,d1             ; input file handle
  52.             move.l #BufAdr,d2        ; input buffer address
  53.             move.l #BufSize,d3       ; input buffer size
  54.             jsr    _LVORead(A6)      ; so read it
  55.             move.l d0,d5             ; size of data
  56. ; Here's where we scan and output
  57.             moveq  #0,d4             ; start of buffer pointer
  58.             lea    BufAdr,a4
  59. ; Character loop; are we at end of buffer?
  60. NextChar    cmp.l  d5,d4
  61.             bge   EndBuf
  62. ; We have data!  Let's crunch it.
  63.             move.b $0(a4,d4),d0
  64.             addq   #1,d4
  65.             cmp.b  #$0a,d0
  66.             beq    NuLiner
  67.             cmp.b  #$20,d0
  68.             bge    NotDot
  69.             move.b #$2e,d0
  70. NotDot      move.b d0,OutBuf
  71.             move.l a5,d1             ;file handle
  72.             move.l #OutBuf,d2        ;buffer
  73.             moveq  #1,d3             ;length
  74.             jsr    _LVOWrite(A6)
  75. ; count and send NewLine if needed
  76.             addq   #1,d7             ;bump column count
  77.             cmp.b  #64,d7            ; at limit?
  78.             blt    NextChar
  79. NuLiner     move.b #$0a,OutBuf
  80.             move.l a5,d1             ;file handle
  81.             move.l #OutBuf,d2        ;buffer
  82.             moveq  #1,d3             ;length
  83.             jsr    _LVOWrite(A6)
  84.             move.l a6,d7             ;stash DOSbase
  85.  
  86.             moveq  #0,d0
  87.             move.l #$1000,d1
  88.             movea.l $4,a6
  89.             jsr    _LVOSetSignal(A6) ;test CTRL-C
  90.             move.l d7,a6             ;restore DOSBase
  91.             andi.l #$1000,d0
  92.             tst.l  d0
  93.             beq    NotCtrlC
  94.             move.l a5,d1             ;file handle
  95.             move.l #CtrlCMess,d2     ;buffer
  96.             moveq  #3,d3             ;length
  97.             jsr    _LVOWrite(A6)
  98.             moveq  #0,d5             ;zap buffer causing exit
  99. NotCtrlC    moveq  #0,d7             ;colcount = 0
  100.             bra    NextChar
  101. ; The buffer is bare.  If twas full, refill it.
  102. EndBuf      cmp.w  #BufSize,d5       ; was it a full buffer?
  103.             beq    ReadBlock         ; yes, get more
  104.             rts                      ; no, we're done
  105. dosname     dc.b 'dos.library',0
  106. CtrlCMess   dc.b '^C',$0a
  107. OutBuf      dc.b  0
  108. BufSize     EQU  10
  109. BufAdr      dc.b  0,0,0,0,0,0,0,0,0,0
  110.  
  111.  
  112.    end
  113.